package com.ruoyi.system.service.evaluationService.evaluationServiceImpl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.evaluation.Complaint;
import com.ruoyi.system.domain.evaluation.ComplaintandStore;
import com.ruoyi.system.domain.evaluation.SuggestionEntity;
import com.ruoyi.system.mapper.evaluation.SuggestionMapper;
import com.ruoyi.system.service.evaluationService.SuggestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuggestionServiceImpl  implements  SuggestionService{
    @Autowired
    private SuggestionMapper suggestionMapper;

    @Override
    public List<Complaint> selectSuggestion() {
        return suggestionMapper.selectSuggestion();
    }

    @Override
    public List<SuggestionEntity> selectSuggestionEntity(String storeName, String location_id) {
        String flag = storeName +location_id ;
        List<SuggestionEntity> list =null;
        if (StringUtils.isEmpty(flag)){
            list = suggestionMapper.selectSuggestionEntity();
        }else if (StringUtils.isNotEmpty(storeName)){
            list = suggestionMapper.selectSuggestionByStoreName(storeName);
        }else if (StringUtils.isNotEmpty(location_id)){
            list = suggestionMapper.selectSuggestionByLocation_id(location_id);
        }else{
            list = suggestionMapper.selectSuggestionEntity();
        }
        return list;
    }

    @Override
    public List<SuggestionEntity> selectSuggestionExport(String ids) {
        Long[] suggestionIds = Convert.toLongArray(ids);
        return suggestionMapper.selectSuggestionExport(suggestionIds);
    }

    @Override
    public int deleteSuggestion(String ids) {
        Long[] suggestionIds = Convert.toLongArray(ids);

        return suggestionMapper.deleteSuggestion(suggestionIds);
    }
}
